import service from '@/utils/request'

export const getUserApiUrl = (name:string)=>{
	if(name=='page'){
		return '/sys/user/list';
	}else if(name=='delete'){
		return '/sys/user/del';
	}else if(name=='role.delete'){
		return '/sys/role/user/del?ids=';
	}else if(name=='role.user'){
		return '/sys/role/user/list?role_id=';
	}
	return "";
}

export const useUserInfoApi = () => {
	return service.get('/sys/user/info')
}

export const updatePasswordApi = (data: any) => {
	return service.post('/sys/user/password', data)
}

export const useUserApi = (id: number) => {
	return service.get('/sys/user/get?ids=' + id)
}

export const useUserSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.post('/sys/user/edit', dataForm)
	} else {
		return service.post('/sys/user/add', dataForm)
	}
}
